<?php

function draw_checkcode_box() {
	echo '<div class="check_code">';
		echo '<img id="check_code_pic" src="checkcode.php"/><br/>';
		echo '<a onclick="' . str_to_html('$("check_code_pic").src="checkcode.php?i="+Math.random();') . '">' . _d('check_code_refresh') . '</a><br/>';
	echo '</div>';
}

function draw_simple_form_head($method,$action) {
	echo "<form method='$method' action=\"$action\">";
}
function draw_simple_form_hidden($hidden) {
	foreach($hidden as $key=>$val) {
		$html_val=htmlspecialchars($val);
		echo "<input type='hidden' name='$key' value=\"$html_val\" />";
	}
}
function draw_simple_form_fillin($fillin) {
	echo '<table align=center>';
		foreach($fillin as $key=>$val){
			echo '<tr><td>' . htmlspecialchars($val[1]) . '</td><td>';
			if($val[0]=='html') {
				echo $val[2];
			} else if($val[0]=='option') {
				Draw_Options($val['list'],$key,$val[2],$val[3]);
			} else if($val[0]=='check') {
				echo '<input name="checkcode" style="width:4em;" />';
				draw_checkcode_box();
			} else {
				$html_val=htmlspecialchars($val[2]);
				if($val[0]=='input') {
					echo "<input name='$key' value=\"$html_val\" {$val[3]} />";
				} else if($val[0]=='textarea') {
					echo "<textarea name='$key' {$val[3]}>$html_val</textarea>";
				} else if($val[0]=='submit') {
					echo "<input type='submit' value=\"$html_val\" {$val[3]} />";
				}
			}
			echo $val[4];
			echo '</td></tr>';
		}
	echo '</table>';
}
function draw_simple_form_foot() {
	echo '</form>';
}
function draw_simple_form($method,$action,$hidden,$fillin) {
//二栏form
//$hidden[$name]=$value_text
//$fillin[$name]=array(
//	0=>{html|input|textarea|option|submit|check}, 
//	1=>$left_text, 
//	2=>$right_default_text
//	3=>$right_tag_property
//	4=>$right_to_right_extra_html
//	'list'=>$option_list
//)
	draw_simple_form_head($method,$action);
	draw_simple_form_fillin($fillin);
	draw_simple_form_hidden($hidden);
	draw_simple_form_foot();
}

?>
